<?php

namespace Console\Controller;

use Common\Controller\BaseController;

class AuthController extends BaseController {

    private $userInfo;

    public function _initialize() {
        parent::_initialize();
        $authLogic = A('Console/Auth', 'Logic');
        $userInfoRes = $authLogic->getUserInfo();
        if (static::$res->isErr($userInfoRes)) {
            redirect(C("WEB_DOMAIN") . "/Login/index");
            exit;
        }

        $userInfo = $userInfoRes["Result"];
        $this->setUserInfo($userInfo);

        //进行数据备份
        $path = WEB_PATH . "/Backups/" . date("Y-m-d", time());
        if (!is_dir($path)) {
            $backupsLogic = A('Console/Backups', 'Logic');
            $backupsLogic->toSql();
        }
    }

    /**
     * 设置当前用户信息
     * @param type $userInfo
     */
    public function setUserInfo($userInfo) {
        $this->userInfo = $userInfo;
    }

    /**
     * 获取当前用户信息
     * @return type
     */
    public function getUserInfo() {
        return $this->userInfo;
    }

}
